package com.zuper.demo.sessionlogin.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyWebMvcConfig implements  WebMvcConfigurer{
	//全局跨域配置
	//@20190628 使用nginx代理转发
//	@Override
//	public void addCorsMappings(CorsRegistry registry) {
//		registry.addMapping("/**") //添加映射路径
//	        	.allowedOrigins("http://localhost:8081") //放行哪些原始域
//		        .allowedMethods("*") //放行哪些原始域(请求方式) //"GET","POST", "PUT", "DELETE", "OPTIONS"
//		        .allowedHeaders("*") //放行哪些原始域(头部信息)
//		        .allowCredentials(true) //是否发送Cookie信息
//				.maxAge(1800);
//	}
	
	//注册拦截器
	@Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyLoginInterceptor())
        		.addPathPatterns("/**")
        		.excludePathPatterns("/login")
        		.excludePathPatterns("/invalidateSession");
        		//.excludePathPatterns("/static/**");
    }
}
